package ec.edu.uce.tour.web.menu.controller;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.MenuModel;

import ec.edu.uce.tour.web.menu.componente.DefaultSubMenuSlideDown;

@ManagedBean
@SessionScoped
public class MenuBean {

	private DefaultMenuModel model;

    public MenuBean() {
    	model = new DefaultMenuModel(); 
		
		
		//First submenu
		
    	
    	//DefaultSubMenu menuPrueba = new DefaultSubMenu();
    	DefaultSubMenuSlideDown menuPrueba = new DefaultSubMenuSlideDown();
    	menuPrueba.setId("menu_tour");
    	menuPrueba.setStyleClass("menu_tour");
    	menuPrueba.setValueDesc("NO");
    	menuPrueba.setValueTitle("Gabo");//{facesContext.externalContext.request.contextPath}
    	menuPrueba.setIcon(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/resources/images/1.jpg");
    	DefaultMenuItem item = new DefaultMenuItem("External");
 		item.setUrl("http://www.primefaces.org");
        item.setIcon("ui-icon-home");
        item.setStyleClass("estiloItem");
        menuPrueba.addElement(item);
        
    	DefaultMenuItem item2 = new DefaultMenuItem("dos");
 		//item2.setUrl("http://www.primefaces.org");
        //item2.setIcon("ui-icon-home");
       // item2.setStyleClass("estiloItem");
 		DefaultSubMenuSlideDown menuPrueba2 = new DefaultSubMenuSlideDown();
    	menuPrueba2.addElement(item2);
    	menuPrueba2.setId("menu_tour");
    	menuPrueba2.setStyleClass("menu_tour");
    	menuPrueba2.setValueDesc("NO");
    	menuPrueba2.setValueTitle("Gabo");
    	//{facesContext.externalContext.request.contextPath}
    	menuPrueba2.setIcon(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/resources/images/2.jpg");
    	menuPrueba.addElement(item2);
    	item2.setOnclick("updateContenedor('../index.html')");
    	item2.setTarget("frameContenedor");
 		DefaultSubMenuSlideDown menuPrueba3 = new DefaultSubMenuSlideDown();
    	menuPrueba3.addElement(item2);
    	menuPrueba3.setId("menu_tour");
    	menuPrueba3.setStyleClass("menu_tour");
    	menuPrueba3.setValueDesc("NO");
    	menuPrueba3.setValueTitle("Gabo");
    	//{facesContext.externalContext.request.contextPath}
    	menuPrueba3.setIcon(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/resources/images/2.jpg");
    	menuPrueba.addElement(item2);
    	item2.setOnclick("updateContenedor('../index.html')");
    	item2.setTarget("frameContenedor");
        model.addElement(menuPrueba);
        model.addElement(menuPrueba2);
        model.addElement(menuPrueba3);
        /*<li>
		 * <a href="#"> <img src="${facesContext.externalContext.request.contextPath}/resources/images/1.jpg" />
					<span class="sdt_active"></span> 
					<span class="sdt_wrap"> 
						<span class="sdt_link">Portfolio</span> 
						<span class="sdt_descr">My	work</span>
					</span>
			</a>
			<div class="sdt_box">
				<a href="#">Websites</a> <a href="#">Illustrations</a> <a href="#">Photography</a>
			</div>
		 *</li> 
		 * */
        /*
         * <li class="ui-menuitem ui-widget ui-corner-all" role="menuitem">
         * <a tabindex="-1" class="ui-menuitem-link ui-corner-all estiloItem" href="http://www.primefaces.org">
         * <span class="ui-menuitem-icon ui-icon ui-icon-home"></span>
         * <span class="ui-menuitem-text">External</span></a>
         * </li>
         * */
        
        
        
        
        

	}

	public MenuModel getModel() {
		return model;
	}	
    
    public void save() {
		addMessage("Data saved");
	}
	
	public void update() {
		addMessage("Data updated");
	}
	
	public void delete() {
		addMessage("Data deleted");
	}

    public String redirect() {
		return "home?faces-redirect=true";
	}
	
	public void addMessage(String summary) {
		FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
}
                    